package jwlee.testproxy.staticproxy;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

/**
 * 静态代理，只针对一个接口
 * 自定义代理模式. 通过面向接口编程,代理实现日志输出
 */
public class TimeBookStaticProxy {
	private Logger logger = Logger.getLogger(this.getClass().getName());

	private TimeBookInterface timeBookInterface;

	// 在该类中针对前面的接口TimeBookInterface编程，而不针对具体的类
	public TimeBookStaticProxy(TimeBookInterface timeBookInterface) {
		this.timeBookInterface = timeBookInterface;
	}

	// 实际业务处理
	public void doAuditing(String name) {
		logger.log(Level.INFO, name + " 开始审核数据....");

		timeBookInterface.doAuditing(name);

		logger.log(Level.INFO, name + " 审核数据结束....");
	}

	public static void main(String[] args) {
		// 这里针对接口进行编程
		TimeBookStaticProxy timeBookProxy = new TimeBookStaticProxy(new TimeBook());
		timeBookProxy.doAuditing("张三");
	}
}
